def partition(numbers, number):
    index = 0
    while index < len(numbers) and numbers[index] < number:
        index += 1
    numbers.insert(index, number)
    return index+1

# === DO NOT modify the code below ===
def main():
    numbers = [ eval(x) for x in input().split() ]
    x = eval(input())
    index = partition(numbers, x)
    print(" ".join(map(str,numbers)))
    print(index)
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===